using System.Data;

namespace Dapper.Bulk;

public static class BulkExtensions
{
    public static Task<int> BulkInsertAsync<T>(this IDbConnection connection, IEnumerable<T> entities) where T : class
    {
        var bulkOps = new BulkOperations(connection);
        return bulkOps.BulkInsertAsync(entities);
    }

    public static Task<int> BulkUpdateAsync<T>(this IDbConnection connection, IEnumerable<T> entities) where T : class
    {
        var bulkOps = new BulkOperations(connection);
        return bulkOps.BulkUpdateAsync(entities);
    }

    public static Task<int> BulkDeleteAsync<T>(this IDbConnection connection, IEnumerable<T> entities) where T : class
    {
        var bulkOps = new BulkOperations(connection);
        return bulkOps.BulkDeleteAsync(entities);
    }

    public static Task<int> BulkMergeAsync<T>(this IDbConnection connection, IEnumerable<T> entities) where T : class
    {
        var bulkOps = new BulkOperations(connection);
        return bulkOps.BulkMergeAsync(entities);
    }

    public static Task<int> BulkSynchronizeAsync<T>(this IDbConnection connection, IEnumerable<T> entities) where T : class
    {
        var bulkOps = new BulkOperations(connection);
        return bulkOps.BulkSynchronizeAsync(entities);
    }
}